package com.miniapp.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.miniapp.entity.ApiAccessLog;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;

/**
 * @author author
 * @date 2025-09-18 15:28
 */
public interface ApiAccessLogMapper extends BaseMapper<ApiAccessLog> {

    /**
     * 物理删除指定时间之前的日志
     *
     * @param createTime 最大时间
     * @param limit      删除条数，防止一次删除太多
     * @return 删除条数
     */
    @Delete("DELETE FROM infra_api_access_log WHERE create_time < #{createTime} LIMIT #{limit}")
    Integer deleteByCreateTimeLt(@Param("createTime") LocalDateTime createTime, @Param("limit") Integer limit);

}
